package com.gdupt.controller;

import com.gdupt.entity.SystemUser;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/views")
public class PageJumpController {
    @RequestMapping("/{name}")
    public void PageJump(HttpServletResponse response, HttpServletRequest request, @PathVariable("name") String name){
        System.out.println(name);
        String name1 = name;
        try {
            //response.sendRedirect("/views/"+name1+".jsp");
            request.getRequestDispatcher("/views/"+name1+".jsp").forward(request,response);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ServletException e) {
            e.printStackTrace();
        }
    }
    @RequestMapping("/{name}/{name2}")
    public void PageJump1(HttpServletResponse response,HttpServletRequest request, @PathVariable("name") String name,@PathVariable("name2") String name2){
        String name1 = name;
        try {
            //response.sendRedirect("/views/"+name1+"/"+name2+".jsp");
            request.getRequestDispatcher("/views/"+name1+"/"+name2+".jsp").forward(request,response);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ServletException e) {
            e.printStackTrace();
        }
    }
}
